package com.ylkj.bus.dispatcher;


import com.hwl.datahub.DataHubReaderConfig;
import com.ylkj.Application;
import com.ylkj.bus.MessageContent;
import com.ylkj.bus.dispatcher.handler.ReportAppStreamHandler;
import org.apache.flink.streaming.api.datastream.DataStream;

import java.util.Properties;

public enum DispatcherHandler {
    //    app 状态上报
    REP_APP_STATUS {
        @Override
        protected IStreamHandler getHandler(Properties flinkProperties) {
            String tableName1 = flinkProperties.getProperty("reportApp.rds.tableName1");
            String tableName2 = flinkProperties.getProperty("reportApp.rds.tableName2");
            String tableName4 = flinkProperties.getProperty("reportApp.rds.tableName4");


            return new ReportAppStreamHandler(
                    Application.getRdsConfig(flinkProperties),
                    tableName1,
                    tableName2,
                    tableName4,
                    Application.getDataHubSinkConfig(flinkProperties)
            );
        }
};

    protected abstract IStreamHandler getHandler(Properties flinkProperties );

    public void dispatch(DataStream<MessageContent> stream, Properties flinkProperties ) {
        getHandler(flinkProperties).handle(stream);
    }
}
